package com.google.common.io;

import java.io.IOException;
import java.io.InputStream;

public abstract class ByteSource {
    private static final byte[] countBuffer = new byte[4096];

    public abstract InputStream openStream() throws IOException;

    public byte[] read() throws IOException {
        Closer closer = Closer.create();
        try {
            byte[] toByteArray = ByteStreams.toByteArray((InputStream) closer.register(openStream()));
            closer.close();
            return toByteArray;
        } catch (Throwable th) {
            closer.close();
        }
    }
}
